#ifndef MY_SLAVE_H
#define MY_SLAVE_H

#include <athread.h>
#include <crts.h>
#include "pcg_def.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __sw_slave__
    #undef SLAVE_FUN
    #define SLAVE_FUN(name) name
#endif

typedef struct {
    int* input;
    int cells;
    int faces;

    uint8_t* output;
} CountingParam;
void SLAVE_FUN(counting)(CountingParam* param);

typedef struct {
    // 对角线元素
    double* diag;
    // pcg_solve 函数的两个输入参数
    double* source;
    double* x;
    // LDU 矩阵
    int* lPtr;
    int* uPtr;
    double* data;
    // 向量长度
    int cells;
    // 非零元素数
    int faces;
} LoadInputParam1;

void SLAVE_FUN(load_input_param1)(LoadInputParam1* param);

void SLAVE_FUN(load_input_param2)(struct CsrMatrix* param);

typedef struct {
    /* Input */
    // pcg_solve 的其它输入参数
    int maxIter;
    double tolerance;
    double normfactor;

    /* Output */
    struct PCGReturn* result;

    // load para2
    struct CsrMatrix* csr_matrix;

    double* x;  // 最终结果
} RunParam;

void SLAVE_FUN(run)(RunParam* param);

#ifdef __cplusplus
}
#endif

#endif